// 时间戳格式使用
/**
 *
 * @param stamp 时间戳(number)
 * @param format 时间格式(YYYY-MM-DD HH:mm:ss)
 * @returns 时间格式(format)
 */
const dateFromatStamp = (stamp) => {
  if (String(stamp).length <= 10) {
    stamp = stamp * 1000
  }
  const timeContent = stamp * 1
  let data = new Date(timeContent)
  const year = data.getFullYear()
  const month =
    data.getMonth() + 1 < 10 ? "0" + (data.getMonth() + 1) : data.getMonth() + 1
  const day = data.getDate() < 10 ? "0" + data.getDate() : data.getDate()
  return `${year}-${month}-${day}`
}

module.exports = {
  dateFromatStamp,
}
